Total Complexity | 2 |
Total Lines | 23 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | import { MigrationInterface, QueryRunner } from 'typeorm'; |
||
2 | |||
3 | export class CreateNotificationTable1717147942177 |
||
4 | implements MigrationInterface { |
||
5 | name = 'CreateNotificationTable1717147942177'; |
||
6 | |||
7 | public async up(queryRunner: QueryRunner): Promise<void> { |
||
8 | await queryRunner.query( |
||
9 | `CREATE TYPE "public"."notification_type_enum" AS ENUM('post', 'comment', 'reaction')` |
||
10 | ); |
||
11 | await queryRunner.query( |
||
12 | `CREATE TABLE "notification" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "public"."notification_type_enum" NOT NULL, "resourceId" character varying NOT NULL, "message" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "leaveRequestId" uuid, CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY ("id"))` |
||
13 | ); |
||
14 | await queryRunner.query( |
||
15 | `ALTER TABLE "notification" ADD CONSTRAINT "FK_d7dcd7fa90cc4542719b880bc7f" FOREIGN KEY ("leaveRequestId") REFERENCES "leave_request"("id") ON DELETE SET NULL ON UPDATE NO ACTION` |
||
16 | ); |
||
17 | } |
||
18 | |||
19 | public async down(queryRunner: QueryRunner): Promise<void> { |
||
20 | await queryRunner.query( |
||
21 | `ALTER TABLE "notification" DROP CONSTRAINT "FK_d7dcd7fa90cc4542719b880bc7f"` |
||
22 | ); |
||
23 | await queryRunner.query(`DROP TABLE "notification"`); |
||
24 | await queryRunner.query(`DROP TYPE "public"."notification_type_enum"`); |
||
25 | } |
||
27 |